<?php
$this->breadcrumbs=array(
	'Advertisements',
);

if (Yii::app()->user->name=='admin') {
	$this->menu=array(
		array('label'=>'Create', 'url'=>array('create')),
	);
}

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('advertisement-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Advertisements</h1>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'advertisement-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'number',
		array(
			'name'=>'typeId',
			'header'=>'Type',
			'value'=>'$data->type->name',
			'filter'=>AdvertisementType::model()->getAllTypes(),
		),
		'title',
		'endTime',
		/*
		 * 
		'startTime',
		'size',
		'content',
		'client',
		'clientPhone',
		'clientEmail',
		'clientAddress',
		'price',
		'paymentType',
		'paymentDate',
		'memo',
		*/
		array(
			'class'=>'CButtonColumn',
			'template'=>Yii::app()->user->name=='admin'?'{view} {update} {delete}':'{view}',
		),
	),
)); ?>
